package cdms.db;


import cdms.domain.DeliveryOrder;
import cdms.web.PaginationSupport;

import java.util.List;

public interface DeliveryOrderRepository {
	
	/**
	 * get the number of delivery orders
	 * @return
	 */
	long count();
	
	/**
	 * get the count of search in all
	 * @param type
	 * @param search
	 * @return
	 */
	long searchCount(String type, String search);
	
	/**
	 * get the count of state
	 * @param state
	 * @return
	 */
	long stateCount(int state);
	
	/**
	 * get the count of search in state
	 * @param type
	 * @param search
	 * @param state
	 * @return
	 */
	long searchStateCount(String type, String search, int state);
	
	/**
	 * get the count of order by senderId
	 * @param senderId
	 * @return long
	 */
	long count(Long senderId);

	/**
	 * add a new delivery order
	 * 
	 * @param deliveryOrder
	 * @return
	 */
	DeliveryOrder save(DeliveryOrder deliveryOrder);
	
	/**
	 * find a order by sender Id
	 * 
	 * @param senderId
	 * @return DeliveryOrder
	 */
	DeliveryOrder findOneBySenderId(Long senderId);
	
	/**
	 * update order information
	 * 
	 * @param order
	 * @return DeliveryOrder
	 */
	DeliveryOrder update(DeliveryOrder order);

	/**
	 * search a delivery order by id
	 * 
	 * @param id
	 * @return
	 */
	DeliveryOrder findOne(Long id);
	
	/**
	 * 
	
	 * <p>Title: findByOrderId</p>  
	
	 * <p>Description: find order by orderId</p>  
	
	 * @param orderId
	 * @return
	 */
	DeliveryOrder findByOrderId(String orderId);

	/**
	 * get the list of delivery orders
	 * 
	 * @return
	 */
	List<DeliveryOrder> findAll();
	
	/**
	 * get delivery orders by pageNo and pageSize
	 * 
	 * @param pageNo
	 * @param pageSize
	 * @param senderId
	 * @return
	 */
	PaginationSupport<DeliveryOrder> findPage(int pageNo, int pageSize, Long senderId, boolean flag);
	
	/**
	 * 
	 * 
	 * @return PaginationSupport<DeliveryOrder>
	 *
	 */
	PaginationSupport<DeliveryOrder> findPage(int pageNo, int pageSize);
	
	/**
	 * get the orders of search in all and show in page
	 * @param pageNo
	 * @param pageSize
	 * @param type
	 * @param search
	 * @return
	 */
	PaginationSupport<DeliveryOrder> searchAllPage(int pageNo, int pageSize, String type, String search);
	
	/**
	 *  get the orders of state and show in page
	 * @param pageNo
	 * @param pageSize
	 * @param type
	 * @param search
	 * @return
	 */
	PaginationSupport<DeliveryOrder> statePage(int pageNo, int pageSize, int state);
	
	/**
	 * get the orders of search in state and show in page
	 * @param pageNo
	 * @param pageSize
	 * @param type
	 * @param search
	 * @return
	 */
	PaginationSupport<DeliveryOrder> searchStatePage(int pageNo, int pageSize, String type, String search,int state);
	
}
